<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>Post Not Support</title>
</head>
<body>
<form class="form" action="" method="post" id="human">
    id:<input name="id" id="id"/><br/>
    名字:<input name="name" id="name"/><br/>
    年龄<input name="age" id="age"/><br/>
    <button type="submit" id="subBtn">提交</button>
</form>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script>
    $(function(){
        var postNotSupport = {
            init: function() {
                this.initEvent();
            },
            initEvent: function() {
                var _this = this;
                // post not support
                // _this.postNotSupport;
                // 提交成功
                _this.validPost();
            },
            postNotSupport: function() {
                var _this = this;
                _this.saveAjax();
            },
            validPost: function() {
                var _this = this;
                $("#human").validate({
                    submitHandler:function(form){
                        _this.saveAjax();
                        return false;
                    }
                });
            },
            saveAjax: function() {
                var human = {
                    id:$("#id").val(),
                    name:$("#name").val(),
                    age:$("#age").val()
                }

                $("#subBtn").on("click", function() {
                    $.ajax({
                        url:"/postNotSupport/save",
                        type:"post",
                        contentType:"application/json",
                        data:JSON.stringify(human),
                        sync:true
                    });
                })
            }
        }
        postNotSupport.init();
    })
</script>
</body>
</html>